﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Security.Cryptography;

namespace AddAudio2Video
{
    class AuthIt
    {
        static public string getKey()
        {
            string key = "";
            string cpuId = HardwareInfo.GetCpuID();
            string hdiskId = HardwareInfo.GetHardDiskID();
            key = getMD5(cpuId + hdiskId + cpuId + cpuId);
            return key;
        }
        static public string getAuthCode()
        {
            string key = getKey();
            string code = getMD5(key+key);
            return code;
        }
        static public string getMD5(string str)
        {
            MD5 md5 = new MD5CryptoServiceProvider();
            byte[] fromData = System.Text.Encoding.Unicode.GetBytes(str);
            byte[] targetData = md5.ComputeHash(fromData);
            string byte2String = null;

            for (int i = 0; i < targetData.Length; i++)
            {
                byte2String += targetData[i].ToString("x");
            }

            return byte2String;
        }
    }
}
